Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespaced invocation #16319

Merged
merged 1 commit into from
Mar 5, 2018
Merged

Conversation

mixonic
Copy link
Member

@mixonic mixonic commented Mar 4, 2018

Replaces #16158

This commit adds support for invoking a component or injecting a service from a module unification namespace. It is in alignment with RFC #309.

Use :: to delimit namespaces from the name of an invocation or injection. For example:

{{! src/ui/components/app-component/template.hbs }}
{{my-addon::addon-component}}
// src/ui/components/app-component/component.js
import { inject } from '@ember/services';
import Component from '@ember/component';

export default Component.extend({
  session: inject('ember-simple-auth::session')
});

@mixonic mixonic force-pushed the namespaced-invocation branch 2 times, most recently from ad81146 to 05c4ada Compare March 5, 2018 01:45
@rwjblue rwjblue self-requested a review March 5, 2018 01:53
rwjblue
rwjblue previously requested changes Mar 5, 2018
Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good! Only had a few inline comments

// pass it to the resolve without the source
normalizedName = expandedFullName;
options = {};
if (!EMBER_MODULE_UNIFICATION) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be passed to the assertion below (instead of a separate conditional)

let normalizedName = fullName;
if (options.source) {
let expandedFullName = container.registry.expandLocalLookup(fullName, options);
if (!EMBER_MODULE_UNIFICATION) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be part of assertion condition

if (helper !== undefined) {
return helper;
}

const { owner, moduleName } = meta;

const options: LookupOptions | undefined = makeOptions(moduleName);
const {name, namespace} = this._parseNameForNamespace(_name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you guard this in the feature flag?

}

private _lookupComponentDefinition(_name: string, meta: OwnedTemplateMeta): Option<ComponentDefinition> {
let {name, namespace} = this._parseNameForNamespace(_name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please guard this in the feature flag?

if (namespaceDelimiterOffset === -1) {
this.name = name;
this.namespace = undefined;
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s tweak this else case to ensure it’s feature flagged

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already guarded in: https://github.com/emberjs/ember.js/pull/16240/files#diff-11c397e816cb737423d40c0a91104f5fR40

packages/ember-runtime/lib/inject.js ensures that options is only passed if the feature flag is enabled 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you

@mixonic mixonic force-pushed the namespaced-invocation branch 2 times, most recently from 39bdf15 to 404ca53 Compare March 5, 2018 06:00
@mixonic mixonic force-pushed the namespaced-invocation branch from 404ca53 to e4fab05 Compare March 5, 2018 15:39
@mixonic mixonic dismissed rwjblue’s stale review March 5, 2018 16:57

Addressed!

@mixonic mixonic merged commit 99c84c0 into emberjs:master Mar 5, 2018
@mixonic mixonic deleted the namespaced-invocation branch March 5, 2018 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants